<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.11.2.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
	<form action="${pageContext.request.contextPath }/animal/animal_add" method="post" enctype="multipart/form-data">
		<div>
			动物名称:<input name="animal.aname"/><br><br>
			图片:<input type="file" name="imgUpload"/><br><br>
			日期:<input name="animal.createDate" onclick="WdatePicker()"/><br><br>
			动物种类:<select name="animal.category.cid" id="cid">
				<option value="0">==请选择==</option>
			</select>
			<br><br>		
			分布范围:<select name="animal.distribution.did" id="did">
				<option value="0">==请选择==</option>
			</select>
			<br><br>
			<input type="submit" value="添加">		
		</div>
	</form>
	<script>
	$(function(){
		$.post(
				"{pageContext.request.contextPath}/animal/animal_showCategory",
				//加载category json数组
				function(data){
					console.log(data);
					var sel = $("#cid");
					//var cate = '${query.cid}';
					for(var j in data){						
							sel.append("<option value='"+data[j].cid+"'>=="+data[j].cname+"==</option>");						
					} 
				},
				"json"
			);
			$.post(
					"{pageContext.request.contextPath}/animal/animal_showDistribution",
					//加载Distribution json数组
					function(data){
						console.log(data)
						var sel = $("#did");
						//var dis = '${query.did}';
						for(var i in data){							
								sel.append("<option value='"+data[i]+"'>=="+data[i].dname+"==</option>");
							}
						
					},
					"json"
				); 
		
	})
	</script>
</body>
</html>